/**
 * Created by zhoulin on 2017/10/6.
 */

var aQuery = window.location.href.split("?");//取得Get参数
var aGET = new Array();
if(aQuery.length > 1)
{
    var aBuf = aQuery[1].split("&");
    for(var i=0, iLoop = aBuf.length; i<iLoop; i++)
    {
        var aTmp = aBuf[i].split("=");//分离key与Value
        aGET[aTmp[0]] = aTmp[1];
    }
}
var app = new Vue({
    el: '#main',
    data: {
    	listLength:0,
        list:[],
        sousuo:""
    },
    methods: {
        submit: function(){//搜索
        	console.log("66666")
            this.$http.post("/index/index/getInfoList", {
                'sousuo': this.sousuo//搜索内容
            }, { emulateJSON: true })
                .then(function (response) {
                    // 响应成功回调
                    console.log(response.data.obj)
                    if(response.data.success){
                    	this.list = response.data.obj;
                    	if(response.data.code == 1){
	                    	this.list = response.data.obj;
		                }else {
		                    this.listLength = response.data.obj;
		                     layer.open({
							      content: response.data.msg
							      ,time: 3
							      ,skin: 'msg'
							    });
		                    //parent.layer.msg(response.data.msg, {icon: 6});
		                }
	                }
                    
                }, function (response) {
                    // 响应错误回调
                    console.log(response.data)
                });
        }

    },
    // 页面刚进入就显示数据
    created: function () {
        this.$http.post('/index/index/infoList', {
        }, { emulateJSON: true })
            .then(function (response) {
                // 响应成功回调
                console.log(response.data)
                if(response.data.success){
                    this.list = response.data.obj;
                }else {
                    this.listLength = 0;
                    layer.open({
					  content: response.data.msg,
					  style: 'font-size: 2rem;color: white;background: rgb(232, 64, 64);', //自定风格
					  shadeClose: true,
					  time: 2
					 
					});
                }

            }, function (response) {
                // 响应错误回调
                console.log(response.data)
            });
    }
})
